package com.back.campus_back.controller;
import com.back.campus_back.domain.OrdersAddVo;
import com.back.campus_back.service.impl.OrdersServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单的控制类")
public class OrdersController {
    @Autowired
    OrdersServiceImpl ordersService;

    /*
     * 查询订单信息按照时间降序显示
     * */
    @ApiOperation("查询订单信息按照时间降序显示")
    @GetMapping("/getOrder/{user_id}")
    public List getOrders(@PathVariable(value = "user_id") int user_id){

        return ordersService.getOrders(user_id);
    }

    /*
     * 生成订单
     * */
    @ApiOperation("生成订单")
    @PostMapping("/addOrders")
    public String addOrders(@RequestBody List<OrdersAddVo> orders){
        return ordersService.addOrders(orders);
    }

    //查询所有订单
    @GetMapping("/findAllOrders")
    public List findAllOrders(){
        List allOrders = ordersService.findAllOrders();
        return allOrders;
    }



}

